<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\PropertyInfo;
use Exception;

/**
 * 资金流水
 */
class PropertyInfoController extends Controller
{
    /**
     * 转入转出列表
     *
     * @ author: zrc
     * @ E-mail:904725327@qq.com
     * @ date: 2018/3/17
     * @access public
     * @param  int    uid    用户ID
     * @return array        记录列表
     */
    public function property_info_list(Request $request)
    {
        $info  = $request->all();

        if (empty($info['uid'])||empty($info['page'])) {
            return respF(1003);
        }

        $uid = $info['uid'];
        $page = $info['page']-1;

        if ($page < 1) {
            return respF(1022);
        }

        $list_a = PropertyInfo::where(['uid' => $uid])->orderBy('id','desc')->paginate(10);

        if (collect($list_a)->count() == 0) {
            return respF(1022);
        } else {
            //处理数据
            foreach ($list_a as $key => $val) {
                $data[$key]['cid'] = $val->cid;
                $data[$key]['c_name'] = $val->currency->name_en;
                $data[$key]['note'] = $val->note;
                $data[$key]['num'] = $val->num;
                $data[$key]['total'] = $val->total;
                $data[$key]['proc'] = $val->proc;
                $data[$key]['type'] = $val->type;
                $data[$key]['deal_type'] = $val->deal_type;
                $data[$key]['created_at'] = $val->created_at->format('Y-m-d H:i:s');
            }
            $list['status'] = 1;
            $list['msg'] = 1;
            $list['data'] = $data;

            return response()->json($list);
        }
    }
}
